<cfparam name="importData" type="query" />
<cfparam name="collection" type="string" />
<cfparam name="returnView" type="string" default="" />
<cfparam name="passback" type="string" default="" />

<cfscript>
	base = new assets.calgrants.com.Base();
	passbackQueryString = base.passbackToQueryString(passback);
</cfscript>

<cfswitch expression="#collection#">
	<cfcase value="followUps">
	
		<cfscript>
			importStudentIDs = ValueList(importData.Student_ID);
			studentGateway = new assets.calgrants.com.gateway.StudentGateway();
			students = studentGateway.query(regionIDs = IIf(IsUserInRole("Regional Admin"), request.authUser.regionID, ""), Organization_ID = IIf(IsUserInRole("Organizer") OR IsUserInRole("Site Contact"), request.authUser.organizationID, ""), studentIDs = importStudentIDs);
			studentIDs = ValueList(students.Student_ID);
		</cfscript>
		
		<script type="text/javascript" language="javascript">
		<!--
			/*refreshWarning = function(studentID) {
				alert(studentID);
			}*/
			$(function() {
				$("#confirmImport").modal();
				resizeModal("confirmImport");	
			})
		//-->
		</script>
		
		<style type="text/css">
			.warn {
				background-color: orange;
			}
			.invalid {
				background-color: red;
			}
		</style>
		
		<cfoutput>
		
			<cfform name="followUpsImportForm" action="#script_name#" method="post" onsubmit="return validate();">
				<cfinput type="hidden" name="action" value="saveFollowUpsImport" />
				<cfinput type="hidden" name="view" value="#returnView#" />
				<cfif IsDefined("passback")>
					<cfloop index="keyValue" list="#passback#" delimiters=";">
						<cfinput type="hidden" name="#ListFirst(keyValue)#" value="#ListLast(keyValue)#" />
					</cfloop>
				</cfif>
				
				<div id="confirmImport" class="modal modal-fullscreen" data-backdrop="static">
					<div class="modal-header">
						<h3>Confirm Import</h3>
					</div>
					<div class="modal-body">
						<div class="container-fluid">
							<div class="row-fluid">
								<div class="span12">
									<p>Please confirm the data from your import file below.</p>
									<p>Items marked as <span style="background-color: orange; padding-left: 6px; padding-right: 6px;">orange</span> have invalid values.  Please correct each value.  Items marked as <span style="background-color: red; padding-left: 6px; padding-right: 6px;">red</span> are students that aren't in your workshops and will not be updated.</p>
									<p>The following fields must be in the import file and are the only fields that will be updated in the student record.</p>
								</div>
							</div>
							<div class="row-fluid">
								<div class="span12">
									<table class="table table-bordered">
										<thead>
											<tr>
												<th>Student ID</th>
												<th>Student</th>
												<th>Status</th>
												<th>FAFSA</th>
												<th>CA Dream Act</th>
												<th>Taxes</th>
												<th>Income/Assets</th>
												<th>Cal Grant Deadline</th>
												<th>Cal Grant Requirements</th>
												<th>Other</th>
												<th>Notes</th>
											</tr>
										</thead>
										<tbody>
											<cfloop query="importData">
												<cfif ListFind(studentIDs, Student_ID)>
													<cfinput type="hidden" name="Student_ID" value="#Student_ID#" />
													<cfif Follow_Up_Status eq "Complete">
														<cfset isComplete = true />
													<cfelse>
														<cfset isComplete = false />
													</cfif>
													<tr>
														<td>#Student_ID#</td>
														<td>#First_Name# #Last_Name#</td>
														<td<cfif Follow_Up_Status neq "Not Complete" and Follow_Up_Status neq "Complete"> class="warn"</cfif>>
															<cfselect id="Follow_Up_Status_#Student_ID#" name="Follow_Up_Status_#Student_ID#" required="yes" size="1" message="Status is required for Student ID #Student_ID#" style="width: 150px;">
																<cfif Follow_Up_Status neq "Not Complete" and Follow_Up_Status neq "Complete">
																	<option value="" selected>#Follow_Up_Status#</option>
																</cfif>
																<option value="Not Complete"<cfif Follow_Up_Status eq "Not Complete"> selected</cfif>>Not Complete</option>
																<option value="Complete"<cfif Follow_Up_Status eq "Complete"> selected</cfif>>Complete</option>
															</cfselect>
														</td>
														<td<cfif (isComplete and Follow_Up_FAFSA neq "Yes" and Follow_Up_FAFSA neq "No") OR (NOT isComplete and Follow_Up_FAFSA neq "Yes" and Follow_Up_FAFSA neq "No" and Follow_Up_FAFSA neq "")> class="warn"</cfif>>
															<cfselect id="Follow_Up_FAFSA_#Student_ID#" name="Follow_Up_FAFSA_#Student_ID#" required="#isComplete#" size="1" message="FAFSA is required for Student ID #Student_ID#" style="width: 70px;">
																<option value="">#Follow_Up_FAFSA#</option>
																<option value="Yes"<cfif Follow_Up_FAFSA eq "Yes"> selected</cfif>>Yes</option>
																<option value="No"<cfif Follow_Up_FAFSA eq "No"> selected</cfif>>No</option>
															</cfselect>
														</td>
														<td<cfif (isComplete and Follow_Up_CA_Dream_Act neq "Yes" and Follow_Up_CA_Dream_Act neq "No") OR (NOT isComplete and Follow_Up_CA_Dream_Act neq "Yes" and Follow_Up_CA_Dream_Act neq "No" and Follow_Up_CA_Dream_Act neq "")> class="warn"</cfif>>
															<cfselect id="Follow_Up_CA_Dream_Act_#Student_ID#" name="Follow_Up_CA_Dream_Act_#Student_ID#" required="#isComplete#" size="1" message="CA Dream Act is required for Student ID #Student_ID#" style="width: 70px;">
																<option value="">#Follow_Up_CA_Dream_Act#</option>
																<option value="Yes"<cfif Follow_Up_CA_Dream_Act eq "Yes"> selected</cfif>>Yes</option>
																<option value="No"<cfif Follow_Up_CA_Dream_Act eq "No"> selected</cfif>>No</option>
															</cfselect>
														</td>
														<td<cfif (isComplete and Follow_Up_Taxes neq "Yes" and Follow_Up_Taxes neq "No") OR (NOT isComplete and Follow_Up_Taxes neq "Yes" and Follow_Up_Taxes neq "No" and Follow_Up_Taxes neq "")> class="warn"</cfif>>
															<cfselect id="Follow_Up_Taxes_#Student_ID#" name="Follow_Up_Taxes_#Student_ID#" required="#isComplete#" size="1" message="Taxes is required for Student ID #Student_ID#" style="width: 70px;">
																<option value="">#Follow_Up_Taxes#</option>
																<option value="Yes"<cfif Follow_Up_Taxes eq "Yes"> selected</cfif>>Yes</option>
																<option value="No"<cfif Follow_Up_Taxes eq "No"> selected</cfif>>No</option>
															</cfselect>
														</td>
														<td<cfif (isComplete and Follow_Up_Income_Assets neq "Yes" and Follow_Up_Income_Assets neq "No") OR (NOT isComplete and Follow_Up_Income_Assets neq "Yes" and Follow_Up_Income_Assets neq "No" and Follow_Up_Income_Assets neq "")> class="warn"</cfif>>
															<cfselect id="Follow_Up_Income_Assets_#Student_ID#" name="Follow_Up_Income_Assets_#Student_ID#" required="#isComplete#"  size="1" message="Income/Assets is required for Student ID #Student_ID#" style="width: 70px;">
																<option value="">#Follow_Up_Income_Assets#</option>
																<option value="Yes"<cfif Follow_Up_Income_Assets eq "Yes"> selected</cfif>>Yes</option>
																<option value="No"<cfif Follow_Up_Income_Assets eq "No"> selected</cfif>>No</option>
															</cfselect>
														</td>
														<td<cfif (isComplete and Follow_Up_Cal_Grant_Deadline neq "Yes" and Follow_Up_Cal_Grant_Deadline neq "No") OR (NOT isComplete and Follow_Up_Cal_Grant_Deadline neq "Yes" and Follow_Up_Cal_Grant_Deadline neq "No" and Follow_Up_Cal_Grant_Deadline neq "")> class="warn"</cfif>>
															<cfselect id="Follow_Up_Cal_Grant_Deadline_#Student_ID#" name="Follow_Up_Cal_Grant_Deadline_#Student_ID#" required="#isComplete#" size="1" message="Cal Grant Deadline is required for Student ID #Student_ID#" style="width: 70px;">
																<option value="">#Follow_Up_Cal_Grant_Deadline#</option>
																<option value="Yes"<cfif Follow_Up_Cal_Grant_Deadline eq "Yes"> selected</cfif>>Yes</option>
																<option value="No"<cfif Follow_Up_Cal_Grant_Deadline eq "No"> selected</cfif>>No</option>
															</cfselect>
														</td>
														<td<cfif (isComplete and Follow_Up_Cal_Grant_Requirements neq "Yes" and Follow_Up_Cal_Grant_Requirements neq "No") OR (NOT isComplete and Follow_Up_Cal_Grant_Requirements neq "Yes" and Follow_Up_Cal_Grant_Requirements neq "No" and Follow_Up_Cal_Grant_Requirements neq "")> class="warn"</cfif>>
															<cfselect id="Follow_Up_Cal_Grant_Requirements_#Student_ID#" name="Follow_Up_Cal_Grant_Requirements_#Student_ID#" required="#isComplete#" size="1" message="Cal Grant Requirements is required for Student ID #Student_ID#" style="width: 70px;">
																<option value="">#Follow_Up_Cal_Grant_Requirements#</option>
																<option value="Yes"<cfif Follow_Up_Cal_Grant_Requirements eq "Yes"> selected</cfif>>Yes</option>
																<option value="No"<cfif Follow_Up_Cal_Grant_Requirements eq "No"> selected</cfif>>No</option>
															</cfselect>
														</td>
														<td><cfinput type="text" name="Follow_Up_Other_#Student_ID#" value="#Follow_Up_Other#" style="width: 100px;"></td>
														<td><cfinput type="text" name="Follow_Up_Notes_#Student_ID#" value="#Follow_Up_Notes#" style="width: 100px;"></td>
													</tr>
												<cfelse>
													<tr class="invalid">
														<td>#Student_ID#</td>
														<td>#First_Name# #Last_Name#</td>
														<td colspan="9">You do not have permission to update this student.  It will be omitted from the import.</td>
													</tr>
												</cfif>
											</cfloop>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<a href="?view=#returnView#&#passbackQueryString#" class="btn btn-success">Cancel</a>
						<button type="submit" name="saveButton" class="btn btn-success">Save</button>
					</div>
				</div>
		
			</cfform>
		
		</cfoutput>
		
	</cfcase>
	<cfdefaultcase>
		<div class="alert alert-info notFound">Import procedure not configured</div>
	</cfdefaultcase>
</cfswitch>
	

